Python Scripting for KeyShot 2023 is Broken

I’ve been working with our company’s developer to create a script using python for KeyShot 2023. We were able to reliably create / update cameras using our own script.

We noticed that the documentation online as seen in the link below, does not match the current lux module within KeyShot 2023.

Here’s an Example: lux.setBrightness command
setBrightness%20documentation
Source: https://media.keyshot.com/scripting/doc/2023.2/lux.html

But when we use this function within the KeyShot 2023 scripting console we get an error
setBrightness%20keyshot%20module
Source: KeyShot 2023 scripting console GUI

And when you run >>>help(lux) in the scripting console GUI, the function setBrightness is indeed present
setBrightness%20keyshot%20help(lux)
Source: KeyShot 2023 scripting console GUI running the >>>help(lux) function

=============

  1. Is there or isn’t there a lux.setBrightness function in the module? Maybe is there a more up to date version of the the lux module documentation that we should be referencing?

  2. Is there a Luxion support team we can connect with that can help with python scripting issues?

  3. Basically we are trying to do the following using Python scripts:
    Create New Cameras >> Create New Environments >> Create a New Studio >> Link the Appropriate Camera, Environment and Model Set combo in a Studio >> Render Images
    Does anyone know how we can manipulate studio and link environments to cameras using the scripting console?

Hi @nicholas.caracappa. The doc does state that there is a setBrightness function, but not that it’s installed on the root module lux. Instead it is on the lux.Env class:

Env encapsulates environment settings in a clear and consise way. Get an instance of the active environment using lux.getActiveEnvironment() .

After you’ve gotten an instance of the active environment, you can call the functions listed in the docs, including setBrightness():

env = lux.getActiveEnvironment()
print(env)
print(dir(env))

Yields, for example:

[pyout] <lux.Env | name: "Environment">
[pyout] ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__',
'__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__',
'__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__',
'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__',
'__sizeof__', '__str__', '__subclasshook__', 'getBackgroundColor',
'getBackplateImage', 'getBrightness', 'getFlattenGround',
'getGroundReflections', 'getGroundShadows', 'getGroundShadowsColor',
'getGroundSize', 'getHeight', 'getLightingEnvironment', 'getName',
'getOcclusionGroundShadows', 'getRotation', 'getSize',
'setBackgroundColor', 'setBackplateImage', 'setBrightness',
'setFlattenGround', 'setGroundReflections', 'setGroundShadows',
'setGroundShadowsColor', 'setGroundSize', 'setHeight',
'setLightingEnvironment', 'setOcclusionGroundShadows', 'setRotation',
'setSize']

So you could get/set a test value:

print(env.getBrightness())
env.setBrightness(3.)
print(env.getBrightness())

Yielding, for example:

[pyout] 1.0
[pyout] 3.0

I hope this helps you get started.
/Morten

1 Like

Hi Morten -

Thanks for this response. Is there a “Studio” class or some way to create studios from the scripting console? getActiveStudio() looks like it returns a str, wondering if there is anything hidden that I might be missing?

Appreciate the help,
Aaron

Hi @aaron.bumgarner. That’s unfortunately not possible yet.